{template 'header'}
<link href="./resource/css/app.css" rel="stylesheet">
<ul class="nav nav-tabs">
    <li class="active"><a href="{php echo $this->createWeburl('navigation')}">导航栏管理</a></li>
    <li class=""><a href="{php echo $this->createWeburl('navigation', array('op' => 'addShow'));}">添加导航栏</a></li>
</ul>
<form action="./index.php" method="get" class="form-horizontal">
    <input type="hidden" name="c" value="site">
    <input type="hidden" name="a" value="entry">
    <input type="hidden" name="m" value="bh_farm">
    <input type="hidden" name="do" value="video">
</form>
<div class="panel panel-default">
    <div class="table-responsive panel-body">
        <table class="table table-hover">
            <thead class="navbar-inner">
            <tr>
                <th style="width:80px;">导航名字</th>
                <th style="width:80px;">标识/位置</th>
                <th style="width:80px;">小程序路径</th>
                <th style="width:80px;">选中时图片</th>
                <th style="width:80px;">没选中是图片</th>
                <th style="width:80px;">选中时文字颜色</th>
                <th style="width:80px;">未选时文字颜色</th>
                <th style="width:80px;">顺序</th>
                <th style="width:80px;">时间</th>
                <th style="width:80px;">操作</th>
            </tr>
            </thead>
            <tbody>
            {loop $list $item}
            <tr>
                <td>{$item['name']}</td>
                <td>{$item['position']}</td>
                <td>{$item['path']}</td>
                <td><img src="{php echo getImage($item['selection_image'])}" width="39px" height="39px"></td>
                <td><img src="{php echo getImage($item['unchecked_images'])}" width="39px" height="39px"></td>
                <td>{$item['selection_color']}</span></td>
                <td>{$item['unchecked_color']}</td>
                <td><input type="text" name="sort" class="sort" data-id="{$item['id']}" value="{$item['sort']}" style="width:30px;"></td>
                <td>{php echo date('Y-m-d H:i:s', $item['created'])}</td>
                <td>
                    <a href="{php echo $this->createWeburl('navigation', array('op' => 'editShow', 'id' => $item['id']));}" class="btn btn-success btn-sm">编辑</a>
                    <a href="javascript:;" data-id="{$item['id']}" class="delete btn btn-danger btn-sm">删除</a>
                </td>
            </tr>
            {/loop}
            </tbody>
        </table>
    </div>
    {$pager}
</div>
<script type="application/javascript">
    $(function () {
        $('.delete').click(function () {
            if (!confirm('确认要删除该导航')) {
                return false;
            }
            id = $(this).data('id');
            $.post('', {id:id, op:'delete'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('删除失败');
                }

            }, 'json')
        });

        $('.sort').blur(function () {
            var sort = $(this).val();
            var  id = $(this).data('id');
            $.post('', {id:id,sort:sort, op:'sort'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('排序失败');
                }

            }, 'json')
        });



        $('.is_down').click(function () {
            if (!confirm('确认要' + $(this).html())) {
                return false;
            }
            id = $(this).data('id');
            $.post('', {id:id, op:'down'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('设置失败');
                }

            }, 'json')
        });

        $('.settop').click(function () {

            id = $(this).data('id');
            $.post('', {id:id, op:'settop'}, function (data) {
                if (data.status == 1) {
                    location.href = location.href;
                } else {
                    alert('删除失败');
                }

            }, 'json')
        });
    });

</script>